var BusCon = require("../../core/bus/_con");
var db = require("../../core/db/index");
var config = require("../../core/_include/config");
var ResponObj = require("../_include/responObj");
var BuffCon = require("../../core/buff/_con");
var myfs = require("../_include/fs");
var theme = require("./theme");
var role = require("./role");

module.exports = {
	prefix: "/card_factory",
	get: {
		"/list": function() {
			var query = this.request.query;
			var bus = BusCon.get(query.bus_id);
			if (!bus) {
				throwCusError("找不到指定商家")
			}
			this.body = ResponObj("json", bus.getCardFactoryList(query.num, query.page));
		},
		"/by_id/:card_factory_id": function() {
			var query = this.request.query;
			var bus = BusCon.get(query.bus_id);
			if (!bus) {
				throwCusError("找不到指定商家")
			}
			var card_factory_id = this.params.card_factory_id;
			this.body = ResponObj("json", bus._getCardFactory(card_factory_id));
		},
		"/goods_list_with_page_info/:card_factory_id": function() {
			var query = this.request.query;
			var bus = BusCon.get(query.bus_id);
			if (!bus) {
				throwCusError("找不到指定商家")
			}

			var card_factory_id = this.params.card_factory_id;
			this.body = ResponObj("json", bus.getGoodsListFromCardFactory_PageInfo(card_factory_id, query.num, query.page, query));
		},
		"/goods_list_with_page_info_for_user/:user_id": function() {
			var query = this.request.query;
			var bus = BusCon.get(query.bus_id);
			if (!bus) {
				throwCusError("找不到指定商家")
			}
			var user_id = this.params.user_id;
			this.body = ResponObj("json", bus.getGoodsListFromCardFactoryForUser_PageInfo(user_id, query.num, query.page, query));
		}
	},
}